<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
    String code = request.getParameter("code") == null ? "" : request.getParameter("code");
    String startTime = request.getParameter("startTime") == null ? "" : request.getParameter("startTime");
    String endTime = request.getParameter("endTime") == null ? "" : request.getParameter("endTime");
    String remark = request.getParameter("remark") == null ? "" : request.getParameter("remark");
    String currentPage = request.getParameter("currentPage")==null?"1":request.getParameter("currentPage");
    String totalPage = request.getParameter("totalPage")==null?"0":request.getParameter("totalPage");
    
%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <base href="<%= basePath %>"/>
    <title>收入管理</title>

    <style>
        body {
            background: #f5f6fa;
            font-family: 'Segoe UI', 'Arial', sans-serif;
            margin: 0;
            padding: 0;
        }
        .container {
            max-width: 1500px;
            margin: 32px auto;
            background: #fff;
            border-radius: 12px;
            box-shadow: 0 4px 24px rgba(0,0,0,0.06);
            padding: 32px 40px;
        }
        h2 {
            color: #222;
            margin-bottom: 24px;
        }
        .search-form {
            display: flex;
            flex-wrap: wrap;
            gap: 18px;
            align-items: center;
            margin-bottom: 28px;
        }
        .search-form label {
            font-size: 1rem;
            color: #555;
            margin-right: 6px;
        }
        .search-form input[type="text"], .search-form input[type="date"] {
            padding: 8px 12px;
            border: 1px solid #dcdde1;
            border-radius: 6px;
            font-size: 1rem;
            background: #f9f9f9;
        }
        .search-form input[type="submit"] {
            padding: 8px 28px;
            background: #4f8cff;
            color: #fff;
            border: none;
            border-radius: 6px;
            font-size: 1rem;
            cursor: pointer;
            transition: background 0.2s;
        }
        .search-form input[type="submit"]:hover {
            background: #357ae8;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 12px;
        }
        th, td {
            padding: 10px 8px;
            border-bottom: 1px solid #e0e0e0;
            text-align: center;
        }
        th {
            background: #f0f4ff;
            color: #333;
            font-weight: 600;
        }
        tr:hover {
            background: #f5faff;
        }
        /* 分页美化 */
        .Page {
            margin-top: 20px;
            text-align: center;
        }
        .Page a, .Page strong {
            display: inline-block;
            margin: 0 4px;
            padding: 6px 16px;
            border-radius: 6px;
            font-size: 1rem;
            text-decoration: none;
            color: #4f8cff;
            background: #f0f4ff;
            border: 1px solid #e0e7ff;
            transition: background 0.2s, color 0.2s, border 0.2s;
        }
        .Page a:hover {
            background: #4f8cff;
            color: #fff;
            border: 1px solid #4f8cff;
        }
        .Page strong {
            background: #4f8cff;
            color: #fff;
            border: 1px solid #4f8cff;
            font-weight: bold;
        }
    </style>

</head>
<body>
<div class="container">
    <h2>收入管理</h2>
    <form class="search-form" method="get" action="property_income">
        <input type="hidden" name="method" value="search">
        <input type="hidden" name="currentPage" id="currentPage" value="<%= currentPage %>">
        <label for="code">编号：</label>
        <input type="text" id="code" name="code" value="<%= code %>" placeholder="收入编号">
        <label for="startTime">收入时间：</label>
        <input type="date" id="startTime" name="startTime" value="<%= startTime %>">
        <span>至</span>
        <input type="date" id="endTime" name="endTime" value="<%= endTime %>">
        <label for="remark">备注：</label>
        <input type="text" id="remark" name="remark" value="<%= remark %>" placeholder="备注模糊搜索">
        <input type="submit" value="搜索">
    </form>
    <table>
        <thead>
            <tr>
                <th>ID</th>
                <th>编号</th>
                <th>金额</th>
                <th>收入时间</th>
                <th>支付方式</th>
                <th>备注</th>
                <th>创建时间</th>
                <th>更新时间</th>
            </tr>
        </thead>
        <tbody>
        <c:forEach var="item" items="${incomes_select_default}">
            <tr>
                <td>${item.id}</td>
                <td>${item.code}</td>
                <td>${item.money}</td>
                <td>${item.incometime}</td>
                <td>${item.paymentmethod}</td>
                <td>${item.remark}</td>
                <td>${item.createtime}</td>
                <td>${item.updatetime}</td>
            </tr>
        </c:forEach>
        <c:if test="${empty incomes_select_default}">
            <tr><td colspan="9">暂无数据</td></tr>
        </c:if>
        </tbody>
    </table>
    <div style="margin-top: 24px; text-align: right; font-size: 1.2rem; color: #222; font-weight: bold;">
        总收入：<span style="color:#4f8cff;">${totalMoney}</span> 元
    </div>
    <div style="margin-top: 20px; text-align:center;" class="Page">
        <a href="property_income?method=search&currentPage=${currentPage-1>0?currentPage-1:1}&code=${code}&startTime=${startTime}&endTime=${endTime}&remark=${remark}">上一页</a>
        <c:if test="${totalPage>=1}">
            <c:forEach begin="1" end="${totalPage}" var="i">
                <c:choose>
                    <c:when test="${i == currentPage}">
                        <strong>${i}</strong>
                    </c:when>
                    <c:otherwise>
                        <a href="property_income?method=search&currentPage=${i}&code=${code}&startTime=${startTime}&endTime=${endTime}&remark=${remark}">${i}</a>
                    </c:otherwise>
                </c:choose>
            </c:forEach>
        </c:if>
        <a href="property_income?method=search&currentPage=${currentPage+1<=totalPage?currentPage+1:totalPage}&code=${code}&startTime=${startTime}&endTime=${endTime}&remark=${remark}">下一页</a>
    </div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>

</script>
</body>
</html>